Remove the Servant build flag
authorJoey Hess <joeyh@joeyh.name>
Thu, 25 Sep 2025 17:40:06 +0000 (13:40 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 25 Sep 2025 17:40:06 +0000 (13:40 -0400)
Always build with support for annex+http urls and git-annex p2phttp.

BuildFlags.hs
CHANGELOG
CmdLine/GitAnnex.hs
P2P/Http/Client.hs
P2P/Http/Types.hs
P2P/Http/Url.hs
git-annex.cabal
stack.yaml

index 0b306a09f4c94620e48b71236c6c7bbc14e37cf1..53ea8e6fe3d162a5fddaa2f40aee98c5af886cc2 100644 (file)
@@ -52,11 +52,6 @@ buildFlags = filter (not . null)
 #ifdef WITH_MAGICMIME
        , "MagicMime"
 #endif
-#ifdef WITH_SERVANT
-       , "Servant"
-#else
-#warning Building without servant, will not support annex+http urls or git-annex p2phttp.
-#endif
 #ifdef WITH_BENCHMARK
        , "Benchmark"
 #endif
index 1960ff7d55b9b6243473b59c6dd401a394e9d9af..1acce80c4fbcb7849043e64ecdcf7fb1d315c5b6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+git-annex (10.20250926) UNRELEASED; urgency=medium
+
+  * Remove the Servant build flag; always build with support for
+    annex+http urls and git-annex p2phttp.
+
+ -- Joey Hess <id@joeyh.name>  Thu, 25 Sep 2025 13:36:21 -0400
+
 git-annex (10.20250925) upstream; urgency=medium
 
   * Fix bug that made changes to a special remote sometimes be missed when
index 503227887359986fcab9363cbb9185b5b4541d2c..97b6c6196d4568abbf838ae7f300c5d540d20c4d 100644 (file)
@@ -118,9 +118,7 @@ import qualified Command.Upgrade
 import qualified Command.Forget
 import qualified Command.OldKeys
 import qualified Command.P2P
-#ifdef WITH_SERVANT
 import qualified Command.P2PHttp
-#endif
 import qualified Command.Proxy
 import qualified Command.DiffDriver
 import qualified Command.Smudge
@@ -253,9 +251,7 @@ cmds testoptparser testrunner mkbenchmarkgenerator = map addGitAnnexCommonOption
        , Command.Forget.cmd
        , Command.OldKeys.cmd
        , Command.P2P.cmd
-#ifdef WITH_SERVANT
        , Command.P2PHttp.cmd
-#endif
        , Command.Proxy.cmd
        , Command.DiffDriver.cmd
        , Command.Smudge.cmd
index e71e69f28cd3b703fc9ecebdf69d904e6e33bf65..17084f0fec849ea57500058dca40b55c309f2809 100644 (file)
@@ -27,7 +27,6 @@ import Types.NumCopies
 import Types.Remote
 import Annex.Common
 import qualified Git
-#ifdef WITH_SERVANT
 import qualified Annex
 import Annex.UUID
 import Annex.Url
@@ -51,12 +50,10 @@ import qualified Data.Map as M
 import Control.Concurrent.Async
 import Control.Concurrent
 import System.IO.Unsafe
-#endif
 import Data.Time.Clock.POSIX
 import qualified Data.ByteString.Lazy as L
 
 type ClientAction a
-#ifdef WITH_SERVANT
        = ClientEnv
        -> ProtocolVersion
        -> B64UUID ServerSide
@@ -64,9 +61,6 @@ type ClientAction a
        -> [B64UUID Bypass]
        -> Maybe Auth
        -> Annex (Either ClientError a)
-#else
-       = ()
-#endif
 
 p2pHttpClient
        :: Remote
@@ -95,7 +89,6 @@ p2pHttpClientVersions'
        -> (String -> Annex a)
        -> ClientAction a
        -> Annex (Maybe a)
-#ifdef WITH_SERVANT
 p2pHttpClientVersions' allowedversion rmt rmtrepo fallback clientaction =
        case p2pHttpBaseUrl <$> remoteAnnexP2PHttpUrl (gitconfig rmt) of
                Nothing -> error "internal"
@@ -174,10 +167,6 @@ p2pHttpClientVersions' allowedversion rmt rmtrepo fallback clientaction =
                                putTMVar ccv $ Git.CredentialCache $
                                        M.insert (Git.CredentialBaseURL credentialbaseurl) cred cc
                Nothing -> noop
-#else
-p2pHttpClientVersions' _ _ _ fallback () = Just <$> fallback
-       "This remote uses an annex+http url, but this version of git-annex is not built with support for that."
-#endif
 
 clientGet
        :: Key
@@ -188,7 +177,6 @@ clientGet
        -> Maybe FileSize
        -- ^ Size of existing file, when resuming.
        -> ClientAction Validity
-#ifdef WITH_SERVANT
 clientGet k af consumer startsz clientenv (ProtocolVersion ver) su cu bypass auth = liftIO $ do
        let offset = fmap (Offset . fromIntegral) startsz
        withClientM (cli (B64Key k) cu bypass baf offset auth) clientenv $ \case
@@ -220,12 +208,8 @@ clientGet k af consumer startsz clientenv (ProtocolVersion ver) su cu bypass aut
        gather' (S.Yield v s) = LI.Chunk v <$> unsafeInterleaveIO (gather' s)
        
        baf = associatedFileToB64FilePath af
-#else
-clientGet _ _ _ _ = ()
-#endif
 
 clientCheckPresent :: Key -> ClientAction Bool
-#ifdef WITH_SERVANT
 clientCheckPresent key clientenv (ProtocolVersion ver) su cu bypass auth =
        liftIO $ withClientM (cli su (B64Key key) cu bypass auth) clientenv $ \case
                Left err -> return (Left err)
@@ -241,9 +225,6 @@ clientCheckPresent key clientenv (ProtocolVersion ver) su cu bypass auth =
        
        _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                v4 :<|> v3 :<|> v2 :<|> v1 :<|> v0 :<|> _ = client p2pHttpAPI
-#else
-clientCheckPresent _ = ()
-#endif
 
 -- Similar to P2P.Protocol.remove.
 clientRemoveWithProof
@@ -275,7 +256,6 @@ clientRemoveWithProof proof k unabletoremove remote =
        useversion v = v >= ProtocolVersion 3
 
 clientRemove :: Key -> ClientAction RemoveResultPlus
-#ifdef WITH_SERVANT
 clientRemove k clientenv (ProtocolVersion ver) su cu bypass auth =
        liftIO $ withClientM cli clientenv return
   where
@@ -292,15 +272,11 @@ clientRemove k clientenv (ProtocolVersion ver) su cu bypass auth =
        _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                v4 :<|> v3 :<|> v2 :<|> v1 :<|> v0 :<|> _ = client p2pHttpAPI
-#else
-clientRemove _ = ()
-#endif
 
 clientRemoveBefore
        :: Key
        -> Timestamp
        -> ClientAction RemoveResultPlus
-#ifdef WITH_SERVANT
 clientRemoveBefore k ts clientenv (ProtocolVersion ver) su cu bypass auth =
        liftIO $ withClientM (cli su (B64Key k) cu bypass ts auth) clientenv return
   where
@@ -313,12 +289,8 @@ clientRemoveBefore k ts clientenv (ProtocolVersion ver) su cu bypass auth =
                _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                _ :<|>_ :<|> _ :<|> _ :<|> _ :<|>
                v4 :<|> v3 :<|> _ = client p2pHttpAPI
-#else
-clientRemoveBefore _ _ = ()
-#endif
 
 clientGetTimestamp :: ClientAction GetTimestampResult
-#ifdef WITH_SERVANT
 clientGetTimestamp clientenv (ProtocolVersion ver) su cu bypass auth = 
        liftIO $ withClientM (cli su cu bypass auth) clientenv return
   where
@@ -332,9 +304,6 @@ clientGetTimestamp clientenv (ProtocolVersion ver) su cu bypass auth =
                _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                _ :<|> _ :<|>
                v4 :<|> v3 :<|> _ = client p2pHttpAPI
-#else
-clientGetTimestamp = ()
-#endif
 
 clientPut
        :: MeterUpdate
@@ -349,7 +318,6 @@ clientPut
        -- ^ Set data-present parameter and do not actually send data
        -- (v4+ only)
        -> ClientAction PutResultPlus
-#ifdef WITH_SERVANT
 clientPut meterupdate k moffset af contentfile contentfilesize validitycheck datapresent clientenv (ProtocolVersion ver) su cu bypass auth
        | datapresent = liftIO $ withClientM (cli mempty) clientenv return
        | otherwise = do
@@ -435,14 +403,10 @@ clientPut meterupdate k moffset af contentfile contentfilesize validitycheck dat
                _ :<|> _ :<|>
                _ :<|> _ :<|>
                v4 :<|> v3 :<|> v2 :<|> v1 :<|> v0 :<|> _ = client p2pHttpAPI
-#else
-clientPut _ _ _ _ _ _ _ _ = ()
-#endif
 
 clientPutOffset
        :: Key
        -> ClientAction PutOffsetResultPlus
-#ifdef WITH_SERVANT
 clientPutOffset k clientenv (ProtocolVersion ver) su cu bypass auth
        | ver == 0 = return (Right (PutOffsetResultPlus (Offset 0)))
        | otherwise = liftIO $ withClientM cli clientenv return
@@ -463,14 +427,10 @@ clientPutOffset k clientenv (ProtocolVersion ver) su cu bypass auth
                _ :<|> _ :<|>
                _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                v4 :<|> v3 :<|> v2 :<|> v1 :<|> _ = client p2pHttpAPI
-#else
-clientPutOffset _ = ()
-#endif
 
 clientLockContent
        :: Key
        -> ClientAction LockResult
-#ifdef WITH_SERVANT
 clientLockContent k clientenv (ProtocolVersion ver) su cu bypass auth = 
        liftIO $ withClientM (cli (B64Key k) cu bypass auth) clientenv return
   where
@@ -490,9 +450,6 @@ clientLockContent k clientenv (ProtocolVersion ver) su cu bypass auth =
                _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                _ :<|> _ :<|> _ :<|> _ :<|>
                v4 :<|> v3 :<|> v2 :<|> v1 :<|> v0 :<|> _ = client p2pHttpAPI
-#else
-clientLockContent _ = ()
-#endif
 
 clientKeepLocked
        :: LockID
@@ -503,7 +460,6 @@ clientKeepLocked
        -- server. The lock will remain held until the callback returns,
        -- and then will be dropped.
        -> ClientAction a
-#ifdef WITH_SERVANT
 clientKeepLocked lckid remoteuuid unablelock callback clientenv (ProtocolVersion ver) su cu bypass auth = do
        readyv <- liftIO newEmptyTMVarIO
        keeplocked <- liftIO newEmptyTMVarIO
@@ -563,6 +519,3 @@ clientKeepLocked lckid remoteuuid unablelock callback clientenv (ProtocolVersion
                _ :<|> _ :<|> _ :<|> _ :<|>
                _ :<|> _ :<|> _ :<|> _ :<|> _ :<|>
                v4 :<|> v3 :<|> v2 :<|> v1 :<|> v0 :<|> _ = client p2pHttpAPI
-#else
-clientKeepLocked _ _ _ _ = ()
-#endif
index 5da418416f95cb28141819ab2a4de0c1790a5801..05a3f77fe7d94fb21feae25cb7542b65f00c9509 100644 (file)
@@ -19,11 +19,9 @@ import Annex.Common
 import qualified P2P.Protocol as P2P
 import Utility.MonotonicClock
 
-#ifdef WITH_SERVANT
 import Servant
 import Data.Aeson hiding (Key)
 import Text.Read (readMaybe)
-#endif
 import qualified Data.Text as T
 import qualified Data.Text.Encoding as TE
 import qualified Data.ByteString as B
@@ -149,8 +147,6 @@ newtype UnlockRequest = UnlockRequest Bool
 data Auth = Auth B.ByteString B.ByteString
        deriving (Show, Generic, NFData, Eq, Ord)
 
-#ifdef WITH_SERVANT
-
 instance ToHttpApiData Auth where
        toHeader (Auth u p) = "Basic " <> B64.encode (u <> ":" <> p)
 #if MIN_VERSION_text(2,0,0)
@@ -402,5 +398,3 @@ instance PlusClass PutOffsetResultPlus PutOffsetResult where
        dePlus (PutOffsetResultAlreadyHavePlus _) = PutOffsetResultAlreadyHave
        plus (PutOffsetResult o) = PutOffsetResultPlus o
        plus PutOffsetResultAlreadyHave = PutOffsetResultAlreadyHavePlus []
-
-#endif
index b7ec6d22fe0271d8d28e3b776fb6107e30a84370..b2a1e4c2931e6ebcd5c4aedf755144513203162d 100644 (file)
@@ -11,14 +11,12 @@ module P2P.Http.Url where
 
 import Data.List
 import Network.URI
-#ifdef WITH_SERVANT
 import System.FilePath.Posix as P
 import Servant.Client (BaseUrl(..), Scheme(..))
 import Text.Read
 import Data.Char
 import qualified Git
 import qualified Git.Url
-#endif
 
 defaultP2PHttpProtocolPort :: Int
 defaultP2PHttpProtocolPort = 9417 -- Git protocol is 9418
@@ -30,9 +28,7 @@ isP2PHttpProtocolUrl s =
 
 data P2PHttpUrl = P2PHttpUrl
        { p2pHttpUrlString :: String
-#ifdef WITH_SERVANT
        , p2pHttpBaseUrl :: BaseUrl
-#endif
        }
        deriving (Show)
 
@@ -40,21 +36,15 @@ parseP2PHttpUrl :: String -> Maybe P2PHttpUrl
 parseP2PHttpUrl us
        | isP2PHttpProtocolUrl us = case parseURI (drop prefixlen us) of
                Nothing -> Nothing
-#ifdef WITH_SERVANT
                Just u ->
                        case uriScheme u of
                                "http:" -> mkbaseurl Http u
                                "https:" -> mkbaseurl Https u
                                _ -> Nothing
-#else
-               Just _u ->
-                       Just $ P2PHttpUrl us
-#endif
        | otherwise = Nothing
   where
        prefixlen = length "annex+"
 
-#ifdef WITH_SERVANT
        mkbaseurl s u = do
                auth <- uriAuthority u
                port <- if null (uriPort auth)
@@ -75,15 +65,11 @@ parseP2PHttpUrl us
        basepath u = case reverse $ P.splitDirectories (uriPath u) of
                ("git-annex":"/":rest) -> P.joinPath (reverse rest)
                rest -> P.joinPath (reverse rest)
-#endif
 
 unavailableP2PHttpUrl :: P2PHttpUrl -> P2PHttpUrl
 unavailableP2PHttpUrl p = p
-#ifdef WITH_SERVANT
        { p2pHttpBaseUrl = (p2pHttpBaseUrl p) { baseUrlHost = "!dne!" } }
-#endif
 
-#ifdef WITH_SERVANT
 -- When a p2phttp url is on the same host as a git repo, which also uses
 -- http, the same username+password is assumed to be used for both.
 isP2PHttpSameHost :: P2PHttpUrl -> Git.Repo -> Bool
@@ -93,4 +79,3 @@ isP2PHttpSameHost u repo
                Just (map toLower $ baseUrlHost (p2pHttpBaseUrl u)) 
                        ==
                (map toLower <$> (Git.Url.host repo))
-#endif
index b8ee5060ab0b8007b89eeeb0c99c43a28ba23c07..3dfbe76a8192da1c340efe46e8b0a4f4f0c5e016 100644 (file)
@@ -169,9 +169,6 @@ Flag TorrentParser
 Flag MagicMime
   Description: Use libmagic to determine file MIME types
 
-Flag Servant
-  Description: Use the servant library, enabling using annex+http urls and git-annex p2phttp
-
 Flag OsPath
   Description: Use the os-string library and related libraries, for faster filename manipulation
   Default: True
@@ -282,7 +279,13 @@ Executable git-annex
    network-bsd,
    git-lfs (>= 1.2.0),
    clock (>= 0.3.0),
-   crypton
+   crypton,
+   servant,
+   servant-server,
+   servant-client,
+   servant-client-core,
+   warp (>= 3.2.8),
+   warp-tls (>= 3.2.2)
   CC-Options: -Wall
   GHC-Options: -Wall -fno-warn-tabs  -Wincomplete-uni-patterns
   Default-Language: Haskell2010
@@ -309,21 +312,6 @@ Executable git-annex
   if os(linux) || os(freebsd)
     GHC-Options: -optl-Wl,--as-needed
 
-  if flag(Servant)
-    Build-Depends:
-      servant,
-      servant-server,
-      servant-client,
-      servant-client-core,
-      warp (>= 3.2.8),
-      warp-tls (>= 3.2.2)
-    CPP-Options: -DWITH_SERVANT
-    Other-Modules:
-      Command.P2PHttp
-      P2P.Http
-      P2P.Http.Server
-      P2P.Http.State
-
   if flag(OsPath)
     Build-Depends:
       os-string (>= 2.0.0),
@@ -353,8 +341,6 @@ Executable git-annex
       yesod-form (>= 1.4.8),
       yesod-core (>= 1.6.0),
       path-pieces (>= 0.2.1),
-      warp (>= 3.2.8),
-      warp-tls (>= 3.2.2),
       wai,
       wai-extra,
       blaze-builder,
@@ -718,6 +704,7 @@ Executable git-annex
     Command.MinCopies
     Command.OldKeys
     Command.P2P
+    Command.P2PHttp
     Command.P2PStdIO
     Command.PostReceive
     Command.PreCommit
@@ -917,6 +904,9 @@ Executable git-annex
     P2P.Annex
     P2P.Auth
     P2P.Generic
+    P2P.Http
+    P2P.Http.Server
+    P2P.Http.State
     P2P.Http.Types
     P2P.Http.Client
     P2P.Http.Url
index 58a44a292b1b3a51fd3d0b294b38673c2783a59b..f4c26e49aeac30019069612e989e3d7cb59a77a9 100644 (file)
@@ -9,7 +9,6 @@ flags:
     dbus: false
     debuglocks: false
     benchmark: true
-    servant: true
     ospath: true
 packages:
 - '.'